<?php

class Talktangle_Form_Talktangle_Create extends Engine_Form
{
  public function init()
  {
      $viewer = Engine_Api::_()->user()->getViewer();
      
      $this->clearDecorators()
//      ->addDecorator('FormElements')
//      ->addDecorator('Form')
      ->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));

        $this->setTitle('Create Talktangle')
             ->setDescription('Compose your new talktangle below. Click "Mix Tangle" to preview mixed talktangle, and then click "Submit" to post your talktangle.');
        
        $this->addElement('text','title',array(
            'label'=>'Title',
			'required' =>true,
            'allowEmtry'=>false,
            'validators' => array (
					array (
						'NotEmpty', 
						true
					)
			)                                             
        ));
               
        $this->addElement('textarea','content',array(
            'label'=>'Content',
			'required' =>true,
            'allowEmtry'=>false,
            'description' => 'This content will be mixed. Users have to find the original content to Untangle.',
            'validators' => array (
					array (
						'NotEmpty', 
						true
					)
			)                                             
        ));
        
        $this->content->getDecorator("Description")->setOption("placement", "append");
        if($viewer->type == 'company'){
            
            $this->addElement('select','duration',array(
                'label'=>'Duration',
                'multiOptions' => array(
                    'day' => '1 Day',
                    'week' => '1 Week',
                    'month' => '1 Month',               
                ),                               
            ));
    
            $this->addElement('text','pro_title',array(
                'label'=>'Promotion',                                            
            ));

            $this->addElement('File', 'pro_image', array(
              'label' => 'Choose Promptions photo',
              'destination' => APPLICATION_PATH.'/public/temporary/',
              'multiFile' => 1,
              'validators' => array(
                array('Count', false, 1),
                array('Extension', false, 'jpg,png,gif,jpeg'),
              )      
            ));
            
            $this->addElement('textarea','pro_description',array(
                'label'=>'Description',                                            
            ));
            
            $core = Engine_Api::_()->talktangle();
        
            if($core->enableTiwtter()){
                $this->addElement('checkbox','post_tiwtter',array(
                    'label' => 'send to tiwtter'
                )) ;
            }
            
             if($core->enableFacebook()){
                $this->addElement('checkbox','post_facebook',array(
                    'label' => 'send to facebook'
                )) ;
            }
        
    //
    //            
    
    //        $this->addElement('text','ads_title',array(
    //            'label'=>'Ads title',                                            
    //        )); 
    
            $this->addElement('File', 'ads_image', array(
              'label' => 'Choose Ads photo',
              'destination' => APPLICATION_PATH.'/public/temporary/',
              'multiFile' => 1,
              'validators' => array(
                array('Count', false, 1),
                array('Extension', false, 'jpg,png,gif,jpeg'),
              )      
            ));
    
            $this->addElement('textarea','ads_description',array(
                'label'=>'Ads description',         
                'description' => '*Notice: If you want to add ads to your talktangle, you have to pay for a fee of 5 Euro for each talktangle.',                                   
            ));  
            
            $this->ads_description->getDecorator("Description")->setOption("placement", "append");
            
        }        
        
        
       $this->addElement('Hidden', 'preview', array('order' => 100));     
       $this->addElement('Hidden', 'file_id', array('order' => 101));         
       $this->addElement('Hidden', 'pro_file_id', array('order' => 102));     
       
       $this->addElement('Button', 'previewTangle', array (
			'label' => 'Mix Tangle', 
            'onclick' => 'previewTalktangle()',
			'decorators' => array (
				'ViewHelper',
                'DivDivDivWrapper',
			)
		)); 
              
       $this->addElement('Button', 'submit', array (
			'label' => 'Submit', 
			'type' => 'submit',
			'decorators' => array (
				'ViewHelper'
			)
		)); 
       
		$this->addElement('Cancel', 'cancel', array (
				'label' => 'cancel', 
				'link' => true, 
				'href' => '', 
                'onclick' => 'cancelCreate();',
				'decorators' => array (
						'ViewHelper'
				)
		));               

        $this->addDisplayGroup(array('submit', 'cancel'), 'buttons', array(
          'decorators' => array(
            'FormElements',
            'DivDivDivWrapper',
          ),
        ));           
  }
}  